home *** CD-ROM | disk | FTP | other *** search
/ Alles Voor Internet / Tout Pour Internet / alles voor internet.iso / MacInternet™ / Utilities / InstallerMaker™ / InstallerMaker__2.0.2_Installe / InstallerMaker™ 2.0.2 Installer / InstallerMaker Extensions / IMid Extension / IMid.c next >
C/C++ Source or Header  |  1994-05-05  |  3KB  |  134 lines

  1. /*    Aladdin IMid
  2.  
  3.     Raymond Lau  93.05.11
  4.     
  5.     revised 94.03.14 (jam) to use new packages parameter
  6.     revised 94.05.03 (rmt) added "after" parameter, took into account
  7.                            Think C 6.0's stricter type checking, and added 
  8.                            some additional comments.
  9.  
  10.     
  11.     This IMID does the following.
  12.  
  13.     If folder mgr. does not exist:
  14.     
  15.         Aladdin [fldr]                    --> Always in "Extensions" in System
  16.         Files of type 'appe'             --> Always in "Extensions" in System
  17.         Files of type 'thng'             --> Always in "Extensions" in System
  18.         Files of type 'Pref' and 'pref'    --> Always in "Preferences" in System
  19. */
  20.  
  21.  
  22. #include <MacHeaders>
  23. #include <Folders.h>
  24. #include <GestaltEqu.h>
  25. #include <SetUpA4.h>
  26.  
  27.  
  28. void GetSysVolDir(short *vol,long *dir)
  29. {
  30.     HParamBlockRec MyHFB;
  31.     
  32.     if (HFS < 0) {
  33.         *vol = BootDrive;
  34.         *dir = 2;
  35.         return;
  36.     }
  37.     
  38.     GetVRefNum(SysMap,vol);
  39.  
  40.     MyHFB.volumeParam.ioNamePtr = 0;
  41.     MyHFB.volumeParam.ioVRefNum = *vol;
  42.     MyHFB.volumeParam.ioVolIndex = 0;
  43.     PBHGetVInfo(&MyHFB,FALSE);
  44.  
  45.     *dir = MyHFB.volumeParam.ioVFndrInfo[0];
  46. }
  47.  
  48.  
  49. short FindFolderInSystem(unsigned char *name,short *vol,long *dir)
  50. {
  51.     short sysvol;
  52.     long sysdir;
  53.     HParamBlockRec HRec;
  54.     
  55.     GetSysVolDir(&sysvol,&sysdir);
  56.  
  57.     HRec.ioParam.ioNamePtr = (StringPtr)name;
  58.     HRec.ioParam.ioVRefNum = sysvol;
  59.     HRec.fileParam.ioDirID = sysdir;
  60.     HRec.fileParam.ioFDirIndex = 0;
  61.     if(!PBGetCatInfoSync((CInfoPBPtr)&HRec)) {
  62.  
  63.         if(!(HRec.fileParam.ioFlAttrib & 0x10)) {    // not folder
  64.             return TRUE;
  65.         }
  66.         *vol = sysvol;
  67.         *dir = HRec.fileParam.ioDirID;
  68.         
  69.         return FALSE;
  70.     }
  71.  
  72.     HRec.ioParam.ioNamePtr = (StringPtr)name;
  73.     HRec.ioParam.ioVRefNum = sysvol;
  74.     HRec.fileParam.ioDirID = sysdir;
  75.     if(PBDirCreateSync(&HRec)) {
  76.         return TRUE;
  77.     }
  78.     
  79.     *vol = sysvol;
  80.     *dir = HRec.fileParam.ioDirID;
  81.  
  82.     return FALSE;
  83. }
  84.  
  85. pascal short main(short userVol,long userDir,
  86.                         short *destVol,long *destDir,
  87.                         short isFolder,
  88.                         char *name,
  89.                         unsigned long creationDate,
  90.                         unsigned long modificationDate,
  91.                         OSType type,OSType creator,
  92.                         unsigned short packages,
  93.                         short after)
  94. {
  95.     long gest;
  96.     static short thePass = 0 ;
  97.     short result = 0;
  98.     
  99.     RememberA0();
  100.     SetUpA4();
  101.     
  102.     // This makes sense only before we install, so we first check when our
  103.     // IMid is being called:  before or after installation.
  104.     
  105.     if ( !after )
  106.     {
  107.         // Was InstallerMaker able to use System 7 Folder Manager calls?
  108.         if(Gestalt(gestaltFindFolderAttr,&gest) ||
  109.                     !(gest & 1L<<gestaltFindFolderPresent)) {
  110.             
  111.             // We're running under System 6, so we need to redirect some
  112.             // items into the Aladdin folder under a created Extensions folder
  113.             if(isFolder) {
  114.                 if(EqualString( (StringPtr) name,"\pAladdin",FALSE,TRUE)) {
  115.                     if(FindFolderInSystem("\pExtensions",destVol,destDir))
  116.                         result = 2;
  117.                 }
  118.             } else {
  119.                 if(type == 'appe' || type == 'thng') {
  120.                     if(FindFolderInSystem("\pExtensions",destVol,destDir))
  121.                         result = 2;
  122.                 } else if(type == 'Pref' || type == 'pref') {
  123.                     if(FindFolderInSystem("\pPreferences",destVol,destDir))
  124.                         result = 2;
  125.                 }
  126.             }
  127.     
  128.         }
  129.     }
  130.  
  131.     RestoreA4();
  132.     return result;
  133. }
  134.